﻿// =================================================================== 
// 模块说明
//====================================================================
// 创建时间：2018-05-17 14:16:42
// 负责人：Sushee
// ===================================================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq.Expressions;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using OF.Utility;
using OF.Component.Model;
using OF.Component.IDAL;
using System.Text;
using OF.Component.DTO;

namespace OF.Component.DAL
{
	
	/// <summary>
	/// 数据访问层
	/// </summary>	
	internal partial class LogOperation
	{		
    
        /// <summary>
    	/// 根据断言条件获取单个
    	/// </summary>
        public LogOperationInfo QuerySingle(Expression<Func<LogOperationInfo, bool>> predicate)
	    {
            return SQLServerProvider.CreateObject(ConnectionStringKey, predicate);
        }
        /// <summary>
    	/// 根据断言条件获获取列表
    	/// </summary>
	    public IList<LogOperationInfo> QueryList(Expression<Func<LogOperationInfo, bool>> predicate)
	    {
	        return SQLServerProvider.CreateList(ConnectionStringKey, predicate);
	    }

	    public IList<LogOperationDto> SearchList(scLogOperation condition)
	    {
            Database db = DatabaseFactory.CreateDatabase(this.ConnectionStringKey);
            DbCommand dbc = db.GetStoredProcCommand("up_LogOperation_search");

            db.AddInParameter(dbc, "@PlatformID", DbType.Int32, condition.PlatformID);
            db.AddInParameter(dbc, "@StartDate", DbType.String, condition.StartDate);
            db.AddInParameter(dbc, "@EndDate", DbType.String, condition.EndDate);

            db.AddInParameter(dbc, "@PageIndex", DbType.Int32, condition.PageIndex);
            db.AddInParameter(dbc, "@PageSize", DbType.Int32, condition.PageSize);
            db.AddOutParameter(dbc, "@OutCount", DbType.Int32, 4);

            DataSet dr = db.ExecuteDataSet(dbc);
            condition.TotalRecord = (int)db.GetParameterValue(dbc, "@OutCount");

            return SQLServerProvider.CreateList<LogOperationDto>(dr.Tables[0]);
        }
	}
	
}